var NetUtil = {
    httpPost: function (url, obj) {
        console.log('Send Http Post:: ' + url);
        return axios.post(appConfig.webAddr + url, obj);
    },
    httpGamePost: function (url, obj) {
        console.log('Send Http Game Post:: ' + url);
        return axios.post(appConfig.gameAddr + url, obj);
    },
    get: function (route, args, fun) {
        var webAddr = appConfig.webAddr;
        if (typeof args != 'object') {
            if (fun) {
                fun('invalid args', null);
            }
            return;
        }
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function () {
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    var res;
                    try {
                        res = JSON.parse(xhr.responseText);
                        var len = xhr.responseText.length;
                        console.log('从\"' + route + '\""接收到数据', res);
                        if (res.code === 200) {
                            if (fun) {
                                fun('success', res);
                            }
                        } else {
                            if (fun) {
                                fun('failed', res);
                            }
                        }
                    } catch (e) {
                        Log.warn('error ' + e.message + e.stack);
                        fun('str', xhr.responseText);
                    }
                } else {
                    fun('failed', null);
                }
            }
        };

        var formData = {};
        var param = '';
        args["token"] = userInfo.getToken();
        for (var k in args) {
            if (args[k] == undefined) continue;
            param = param + k + '=' + args[k] + '&';
        }
        var random = 'random=' + new Date().getTime();
        var url = webAddr + route + '?' + param + random;
        if (url.indexOf('http://') < 0) {
            url = 'http://' + url;
        }

        xhr.open("get", url);
        xhr.setRequestHeader("Content-Type", "text/javascript;charset=UTF-8");
        xhr.send('data');
    },
}